//
//  HomeHeaderView.m
//  Mtime
//
//  Created by Mac on 15/8/11.
//  Copyright (c) 2015年 wxk. All rights reserved.
//

#import "HomeHeaderView.h"
#import "HomeModel.h"

@implementation HomeHeaderView


- (void)awakeFromNib {

    [super awakeFromNib];
    
    
    
}

- (void)reloadData:(NSInteger)index {

    //最初   初始化时 中间视图加载的model数据
    HomeModel *model = _dataArray[index];
    
    _title.text = model.titleCn;

    _rating.text = [NSString stringWithFormat:@"%@",model.ratingFinal];
    
    if ([model.commonSpecial isEqualToString:@""]) {
        
        _comment.text = [NSString stringWithFormat:@"%@人在期待上映",model.wantedCount];
    }else {
        _comment.text = model.commonSpecial;
    }

}


- (void)setDataArray:(NSMutableArray *)dataArray {

    _dataArray = dataArray;
    
    [self reloadData:1];
    
    _scrollView.dataArray = _dataArray;
    
    [_scrollView getCenterIndex:^(NSInteger index) {
        
        [self reloadData:index];
        
    }];
    
    
}


- (IBAction)noticeAction:(UIButton *)sender {
    
    
    CustomTabbarController *tabbar = (CustomTabbarController *)self.viewController.tabBarController;
    
    [tabbar pushaction:1];
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"notice" object:self];
    
}

- (IBAction)hotMovieAction:(UIButton *)sender {
    
    CustomTabbarController *tabbar = (CustomTabbarController *)self.viewController.tabBarController;
    
    [tabbar pushaction:2];

    [[NSNotificationCenter defaultCenter] postNotificationName:@"hotMovie" object:self];
    
    
}

- (IBAction)newMovieAction:(UIButton *)sender {
    
    CustomTabbarController *tabbar = (CustomTabbarController *)self.viewController.tabBarController;
    
    [tabbar pushaction:2];

    [[NSNotificationCenter defaultCenter] postNotificationName:@"newMovie" object:self];
}

- (IBAction)findCinemaAction:(UIButton *)sender {
    
    CustomTabbarController *tabbar = (CustomTabbarController *)self.viewController.tabBarController;
    
    [tabbar pushaction:3];
}
@end
